<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<meta charset='utf-8' />
	<title>国网云盘系统</title>
	<style>
		.cursers{cursor:pointer}
	</style>
</head>
<body style='background:#ddd;padding:0px;margin:0px;padding-left:10px'>
	<div style='padding:10px;color:blue;font-size:12px'>
		<span onclick='location.replace("share_me.html");sessionStorage.shareAllPnow=1;'>我的共享</span>　
		<span onclick='location.replace("main.html");sessionStorage.shareAllPnow=1;'>文件管理</span>　
	</div>
	<h1 style='text-align:center'>全部共享</h1>

	<div style='padding-left:38px'>
		<select  id='searchSel'>
			<option value="file">按文件名</option>
			<option value="name">按姓名</option>
			<option value="number">按工号</option>
		</select>
		<input type="text" placeholder='输入关键字' id='searchInp' />
		<button id='searchBtn'>搜索</button>
	</div>

	<div id='fileList' style='margin:30px auto'>
		<!--div style='border:0px solid;padding:5px 0'>
			<label><div style='border:0px solid;width:40px;height:35px;float:left;padding-top:7px'></div></label>

			<div style='float:left'><img src="../public/img.png" style='height:35px;width:35px' /></div>
			<div style='float:left'>　　
				<span style='line-height:35px'>aaa</span>　　
				<span style='line-height:35px'>47.57KB</span>　　
				<button>下载</button>　
			</div>
			<div style='clear:both'></div>
		</div-->
	</div>

	<div id='fpage' style='padding-left:38px'></div>
	
</body>
</html>
<script src='../public/jquery1.1.js'></script>
<script src='../public/fun.js'></script>
<script>
//_checkExit();	//检测账号异常强制退出
if(!sessionStorage.shareAllPnow){
	sessionStorage.shareAllPnow = 1;
}


if(!sessionStorage.shareAllMax){
	sessionStorage.shareAllMax = parseInt(sessionStorage.shareAllPnow) + 1;
}
$(function(){


	$('#searchBtn').click(function(){
		var sel = $('#searchSel').find('option:selected').val();
		var inp = m_trim($('#searchInp').val());
		if(!sel || !inp){
			sessionStorage.shareallInp = '';
		}
		sessionStorage.shareAllPnow = 1;
		sessionStorage.shareAllMax = 2;
		sessionStorage.shareallInp = inp;
		sessionStorage.shareallSel = sel;
		location.reload();
	});

	//搜索状态保持
	if(sessionStorage.shareallSel){
		$('#searchSel').val(sessionStorage.shareallSel);
	}
	if(sessionStorage.shareallInp){
		$('#searchInp').val(sessionStorage.shareallInp);
	}

	_getShareAllList();	//获取全部共享文件列表

});	

//获取全部共享文件列表
function _getShareAllList(){
	var view = 0;
	var searchInp = m_trim($('#searchInp').val());
	var searchSel = $('#searchSel').find('option:selected').val();
	var pnow = sessionStorage.shareAllPnow;
	pnow = pnow > 0 ? pnow : 1;
	// if(searchInp){
	// 	var cachePath = '../cache/share_all/' + searchInp + searchSel + pnow;
	// }else{
	// 	var cachePath = '../cache/share_all/' + pnow;
	// }
	// Ajax({},function(cache,xhr_stat,xhr){
	// 	if(!cache || !/^{.*}$/.test(cache)){
			if(view)A('_getShareAllList after');
			var data = {
				type:'_getShareAllList',
				pnow:pnow,
				searchInp:searchInp,
				searchSel:searchSel
			}
			AjaxBefore(data,function(res){
				var tmp = _checkJsonFormat(res); //检测JSON格式
				_parseList(tmp.data);
			});
	// 	}else{
	// 		if(view)A('_getShareAllList cache');
	// 		var tmp_cache = JSON.parse(cache);
	// 		_parseList(tmp_cache.data);
	// 		var expire = tmp_cache.expire*1000;
	// 		var stime = new Date(xhr.getResponseHeader('Date')).getTime();
	// 		if(expire < stime){	//需要更新cache
	// 			AjaxBefore({type:'delCache',path:cachePath},function(res){
	// 				var tmp = _checkJsonFormat(res); //检测JSON格式
	// 			});
	// 		}
	// 	}
	// },cachePath,1);

}



function _parseList(res){
	if(typeof(res) != 'object' || res.length < 0){
		return;
	}
	var str_file = '';

	if(res.length < 1){
		if(sessionStorage.shareAllPnow == 1){
			$('#fileList').html('');
		}else{
			sessionStorage.shareAllPnow = parseInt(sessionStorage.shareAllPnow) - 1;
			sessionStorage.shareAllMax = sessionStorage.shareAllPnow;			
			location.reload();
		}
		return;
	}
	for(var i=0;i<res.length;i++){
		var fileShow = true;
		var size = _getSize(res[i].size);
		var ctime = StampToYmd(parseFloat(res[i].ctime)*1000);
		str_file += "<div style='border:0px solid;padding:5px 0'><div style='border:0px solid;width:40px;height:35px;float:left;padding-top:7px'></div><div style='float:left'><label><img src='../public/file.png' style='height:35px;width:35px' align='top'/></label>　　<span style='line-height:35px'>" + res[i].fname + "</span></label>　　<span style='font-size:12px;color:#88a'>大小：" + size + "</span>　<span style='font-size:12px;color:#88f'>上传时间：" + ctime + "</span>　<span style='font-size:12px;color:#f88'>上传者：" + res[i].name + "</span>　<button onclick=_download('"+res[i].path+"','"+res[i].fname+"')>下载</button></div><div style='clear:both'></div></div>";
	}

	$('#fileList').html(str_file);
	if(!fileShow){
		$('#selectBtnArea').hide();
	}

	Fpage(parseInt(sessionStorage.shareAllPnow),parseInt(sessionStorage.shareAllMax),function(p){
		sessionStorage.shareAllPnow = p;
		sessionStorage.shareAllMax = parseInt(p) + 1;
		_getShareAllList();
	},1,1,'#fpage');

}


</script>

